﻿using UnityEngine;
using System.Collections;
using NetWork.Layer;
using UI;
using System.Collections.Generic;

public class MessageBoxController : MonoBehaviour {

    public GameObject m_kMask;
	public UILabel m_kLabel;
	public GameObject m_kOKBtn;
	public UILabel m_kBtnLabel;

	public bool m_bResend = false;

    public List<UITweener> tweeners;

    void Start()
    {
    	if (m_bResend) {
			m_kMask.SetActive(false);
    	} else {
			m_kMask.SetActive(true);
	        UIEventListener.Get(m_kMask).onClick = OnMaskClick;
        }
    }

    public void OnMaskClick(GameObject obj)
    {
        gameObject.SetActive(false);
    }

	void OnEnable ()
	{
		m_kBtnLabel.text = TableTextBlo.GetText("confirm");//OK

	}


    void OnDisable()
    {
    }

	public void Init (string sLabel, bool bResend)
	{
		m_kLabel.text = sLabel;
		m_bResend = bResend;
		Start();

        foreach (var tweener in tweeners)
        {
            tweener.ResetToBeginning();
            tweener.PlayForward();
        }
    }

	public void Click ()
	{
		if (m_bResend)
		{
			NetAPI.HttpResendTimeOut();
			Destroy(gameObject);
		} else {
			Destroy(gameObject);
			return;
		}
	}
}
